package com.wtgroup.demo.leetcode.q009_回文数;

/**
 * @author dafei
 * @version 0.1
 * @date 2021/4/25 16:04
 */
public class Q009_Test {

    public static void main(String[] args) {
        Q009_Test exe = new Q009_Test();
        boolean res = exe.isPalindrome(12321);
        System.out.println(res);
    }

    /**
     * [备选]
     * @param x int整型
     * @return bool布尔型
     */
    public boolean isPalindrome (int x) {
        // write code here
        if(x<0) {
            return false;
        }
        int xback = x;
        long rev = 0;
        while (x>0) {
            int k = x % 10;
            rev = rev*10 + k;
            x = x/10;
        }

        if(rev>Integer.MAX_VALUE) {
            return false;
        }

        return rev == xback;
    }

}
